<table class="tablesorter">
                                		<thead>
                                			<tr>
                                            <?php
                                            	foreach($report_detail_table_terms as $term_key=>$term_val){
                                            		if(isset($website_report_detail[0]->$term_key)){
                                            			echo '<th>'.$term_val['name'].'</th>';	
                                            		}	
                                            	}
                                            ?>
                                			</tr>
                                		</thead>
										<tbody>
                                        <?php
										$impression_sum = 0;
										$click_sum = 0;
										$income_sum = 0;
										//echo "<pre>";print_r($website_report_detail);echo "</pre>";
                                        foreach ($website_report_detail as $key=>$val) {
                                            echo '<tr>';
                                            foreach ($report_detail_table_terms as $term_key=>$term_val) {
                                                if (isset($val->$term_key)) {
                                                    if ($term_key == 'impression' || $term_key == 'click') {
                                                        echo '<td>'.number_format($val->$term_key).'</td>';
														${$term_key.'_sum'} +=  $val->$term_key;
                                                    } elseif ($term_key == 'ctr') {
                                                        echo '<td>'.number_format($val->$term_key, 2, '.', '').'%</td>';
                                                    } elseif ($term_key == 'income') {
                                                        echo '<td>$'.number_format($val->$term_key).'</td>';
														${$term_key.'_sum'} +=  $val->$term_key;
                                                    } else
                                                        echo '<td>'.($val->$term_key).'</td>';
                                                }
                                            }

                                            echo '</tr>';
                                        }
										
                                        ?>
										<tr>
											<td style="color:#FF3D3D;">總和</td>
											<td>&nbsp;</td>
											<td style="color:#FF3D3D;"><?php echo number_format($impression_sum);?></td>
											<td style="color:#FF3D3D;"><?php echo number_format($click_sum);?></td>
											<td>&nbsp;</td>
											<td style="color:#FF3D3D;"><?php echo '$'.number_format($income_sum);?></td>
											<?php if(isset($website_report_detail[0]->product_source)){ ?>
												<td>&nbsp;</td>
											<?php } ?>
										</tr>
										</tbody>
                                	</table>